package org.liziing.shortlink.admin.controller;

import lombok.RequiredArgsConstructor;
import org.liziing.shortlink.admin.common.convention.result.Result;
import org.liziing.shortlink.admin.remote.ShortLinkServiceActualRemoteService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Url 获取标题
 */
@RestController
@RequiredArgsConstructor
public class UrlTitleController {
    private final ShortLinkServiceActualRemoteService shortLinkServiceActualRemoteService;

    /**
     * 根据 URL 获取网站标题
     * @param url   网站链接
     * @return   网站标题
     */
    @GetMapping("/api/short-link/admin/v1/title")
    public Result<String> getUrlTitle(@RequestParam("url") String url) {
        return shortLinkServiceActualRemoteService.getUrlTitle(url);
    }

}
